import { create, update, remove, query } from '../../../../../framework/service/index';
import { Toast } from 'antd-mobile';


const proIcon = require('../../../../../icons/personal/default-avatar.jpg')
export default {

  namespace: 'simpleInfo',

  state: {
    id: '',
    date: [],
    proIcon: proIcon,
    imgURL: proIcon,
    name: '',
    age: '',
    item:{},
    skillArr: ['技能', '爱好', '测试', '测测试试'],
  },

  subscriptions: {
    setup({ dispatch, history }) {
      history.listen(location => {
        if(location.pathname === '/simple-info') {
          // dispatch({
          //   type: 'query',
          // })
        }
      })
    },
  },



  effects: {
    *query({ payload }, { call, put }) {
      // const { code, data, message } = yield call(query, '/api/applicants/details', {});
      // if ( code == 200 && data ) {
      //   console.log('个人信息',data);
      //   yield put({
      //     type: 'querySuccess',
      //     payload: {
      //       profile: data.profile,
      //     }
      //   })
      // }

      // yield put({
      //   type: 'querySuccess',
      //   payload: {
      //     list: personData
      //   }
      // })

      const skillArr = ['摄影','活动策划','活动策划','活动策划','活动策划']
      // yield put({ type: 'querySuccess',payload:{name: memberList.name}});
      // yield put({ type: 'querySuccess',payload:{age: memberList.age}});
      // yield put({ type: 'querySuccess',payload:{skillArr: skillArr}});
    },
    // *onUploadImg({ payload }, { call, put }) {
    //   console.log('onUploadImg');
    //   console.log(payload.imgURL);
    //   yield put({ type: 'querySuccess',payload:{imgURL:payload.imgURL}});
    // },
    // *putBasic({ payload }, { call, put, select }) {
    //   console.log('qqqqqqqqqqqqqq');
    //   console.log(payload);
    //   const profile = yield select (({simpleInfo}) => simpleInfo.profile);
    //
    //   const result =  Object.assign(profile, payload);
    //   console.log('result');
    //   console.log(result);
    //   yield put({ type: 'querySuccess',payload:{profile:result}});
    // },
    // *onSubmit({ payload }, { call, put, select }) {
    //   const profile = yield select (({simpleInfo}) => simpleInfo.profile);
    //   // const id = yield select (({simpleInfo}) => simpleInfo.id);
    //   const { code, data, message } = yield call(update, `/api/applicant/profile`, profile);
    //
    //   if ( code == 200 && data ) {
    //     Toast.info('已保存', 2);
    //     history.go(-1);
    //   }
    // },
  },

  reducers: {
    querySuccess(state, action) {
      return { ...state, ...action.payload };
    },
  }

};
